跳到主要内容

2.12.4-dataset-and-public-widgets-application

2.12.4 Dataset & Public Widgets Application

For commonly used public data that needs to be shared across forms, first, users need to configure the dataset as the data source. Then set up the data presentation method, which is the public widget. Finally, reference the public widgets through dynamic widgets to retrieve the corresponding data.

2.12.4.1 Application Examples

Scenarios such as filling in courier addresses or ID card addresses require provincial, municipal, and county information. There are 34 provincial-level administrative regions in China, each with different cities and counties. Settings this up each time would be labor-intensive, so dynamic widgets can be used to obtain such data.

2.12.4.1.1 Procedure Steps

Configuration basic data a) Create new basic data, ensuring the data item is checked to allow sub-level creation.

b) Data can be input manually or imported directly using a template; the previous step allowed creating sub-levels, which can be added in this step.

Configure dataset a) Click "Create" on the dataset management page. b) Set the title, the code can be auto-filled or manually defined. c) Select "Basic Data" as the data source (the source is the Basic Data service), then search and select the pre-configured basic data from the previous step.

Configure predefined query: Use the parent enumeration item ID as the query field; configuration return values: After searching from the input parameters, return the name and ID of this parent enumeration item to the form call. For example, use the province ID as a query field to return the names and IDs of all cities under that province.

Configure public widgets a) Click "Create" on the public widgets page. b) Set the title, the code can be auto-filled or manually defined. c) Dataset: Select "Basic Data," then choose the dataset configured in the previous steps. d) Fill-in paramether: The display value is the returned field, while the actual value is the stored value corresponding to the display value.

Dynamic Widget call data a) Drag three dynamic widgets into the layout and set their corresponding settings: Province, City, County. b) Province: Select the data source for public widgets – Province/City/District (Manual). c) City: Select the data source for public widgets – Province/City/District (Manual), and set the input parameter with the query condition: Province.ID as the parent enumeration item.ID. When the input parameter meets the condition, it returns the names of all cities. d) District: Select the data source for public widgets – Province/City/District (Manual), and set the input parameter with the query condition: City.ID as the parent enumeration item.ID. When the input parameter meets the condition, it returns the names of all districts.

2.12.4.1.2 Effect

On the Homepage, when a province is selected, the city dropdown will display the corresponding cities within that province, and the district dropdown will show the relevant districts under the selected city.